<h3>注册</h3>
<form nz-form [formGroup]="form" (ngSubmit)="submit()" role="form">
    <nz-alert *ngIf="error" [nzType]="'error'" [nzMessage]="error" [nzShowIcon]="true" class="mb-lg"></nz-alert>
    <nz-form-item>
        <nz-form-control>
            <nz-input-group nzSize="large" nzAddonBeforeIcon="anticon anticon-user">
                <input nz-input formControlName="mail" placeholder="邮箱">
            </nz-input-group>
            <ng-container *ngIf="mail.dirty && mail.errors">
                <nz-form-explain *ngIf="mail.errors?.required">请输入邮箱地址！</nz-form-explain>
                <nz-form-explain *ngIf="mail.errors?.email">邮箱地址格式错误！</nz-form-explain>
            </ng-container>
        </nz-form-control>
    </nz-form-item>
    <nz-form-item>
        <nz-form-control>
            <nz-popover [nzPlacement]="'right'" [nzTrigger]="'focus'" [(nzVisible)]="visible"
                nzOverlayClassName="register-password-cdk" [nzOverlayStyle]="{'width.px': 240}">
                <nz-input-group nzSize="large" nz-popover nzAddonBeforeIcon="anticon anticon-lock">
                    <input nz-input type="password" formControlName="password" placeholder="至少6位密码，区分大小写">
                </nz-input-group>
                <nz-form-explain *ngIf="password.dirty && password.errors">请输入密码！</nz-form-explain>
                <ng-template #nzTemplate>
                    <div style="padding: 4px 0;">
                        <ng-container [ngSwitch]="status">
                            <div *ngSwitchCase="'ok'" class="success">强度：强</div>
                            <div *ngSwitchCase="'pass'" class="warning">强度：中</div>
                            <div *ngSwitchDefault class="error">强度：太短</div>
                        </ng-container>
                        <div class="progress-{{status}}">
                            <nz-progress
                                [nzPercent]="progress"
                                [nzStatus]="passwordProgressMap[status]"
                                [nzStrokeWidth]="6"
                                [nzShowInfo]="false"></nz-progress>
                        </div>
                        <p class="mt-sm">请至少输入 6 个字符。请不要使用容易被猜到的密码。</p>
                    </div>
                </ng-template>
            </nz-popover>
        </nz-form-control>
    </nz-form-item>
    <nz-form-item>
        <nz-form-control>
            <nz-input-group nzSize="large" nzAddonBeforeIcon="anticon anticon-lock">
                <input nz-input type="password" formControlName="confirm" placeholder="确认密码">
            </nz-input-group>
            <ng-container *ngIf="confirm.dirty && confirm.errors">
                <nz-form-explain *ngIf="confirm.errors?.required">请确认密码！</nz-form-explain>
                <nz-form-explain *ngIf="confirm.errors?.equar">两次输入的密码不匹配！</nz-form-explain>
            </ng-container>
        </nz-form-control>
    </nz-form-item>
    <nz-form-item>
        <nz-form-control>
            <nz-input-group nzSize="large" [nzAddOnBefore]="addOnBeforeTemplate">
                <ng-template #addOnBeforeTemplate>
                    <nz-select formControlName="mobilePrefix" style="width: 100px;">
                        <nz-option [nzLabel]="'+86'" [nzValue]="'+86'"></nz-option>
                        <nz-option [nzLabel]="'+87'" [nzValue]="'+87'"></nz-option>
                    </nz-select>
                </ng-template>
                <input formControlName="mobile" nz-input>
            </nz-input-group>
            <nz-form-explain *ngIf="mobile.dirty && mobile.errors">请输入手机号！</nz-form-explain>
        </nz-form-control>
    </nz-form-item>
    <nz-form-item>
        <nz-form-control>
            <nz-row [nzGutter]="8">
                <nz-col [nzSpan]="16">
                    <nz-input-group nzSize="large" nzAddonBeforeIcon="anticon anticon-mail">
                        <input nz-input formControlName="captcha" placeholder="验证码">
                    </nz-input-group>
                    <nz-form-explain *ngIf="captcha.dirty && captcha.errors">请输入验证码！</nz-form-explain>
                </nz-col>
                <nz-col [nzSpan]="8">
                    <button nz-button nzSize="large" (click)="getCaptcha()" [disabled]="count" class="ant-btn__block">{{ count ? count + 's' : '获取验证码' }}</button>
                </nz-col>
            </nz-row>
        </nz-form-control>
    </nz-form-item>
    <nz-form-item>
        <button nz-button nzType="primary" nzSize="large" type="submit" [nzLoading]="loading" class="submit">
            <span>注册</span>
        </button>
        <a class="login" routerLink="/passport/login">使用已有账户登录</a>
    </nz-form-item>
</form>
